package com.genexususa.eo.bing.test.update;

import com.genexususa.eo.bing.connection.AdGroupManager;
import com.genexususa.eo.bing.test.TestUtil;

public class ConsumeUpdateAdGroups {
    public static void main(String[] args) {
        TestUtil testUtil = new TestUtil();
        String adGroupsRequestsXML =    "<Bing_AdGroupsRequestCollection xmlns=\"L2TMediaDev\">\n" +
                                            "\t<Bing_AdGroupsRequest xmlns=\"L2TMediaDev\">\n" +
                                                "\t\t<GxCampaignId>416149485</GxCampaignId>\n" +
                                                "\t\t<BingCampaignId>" + testUtil.campaignId1 + "</BingCampaignId>\n" +
                                                "\t\t<AdGroupCollection>\n" +
                                                    "\t\t\t<AdGroup>\n" +
                                                        "\t\t\t\t<AdDistribution xmlns=\"https://adcenter.microsoft.com/v8\">Content</AdDistribution>\n" +
                                                        "\t\t\t\t<EndDate xmlns=\"https://adcenter.microsoft.com/v8\">\n" +
                                                            "\t\t\t\t\t<Day xmlns=\"https://adcenter.microsoft.com/api/customermanagement/Entities\">5</Day>\n" +
                                                            "\t\t\t\t\t<Month xmlns=\"https://adcenter.microsoft.com/api/customermanagement/Entities\">9</Month>\n" +
                                                            "\t\t\t\t\t<Year xmlns=\"https://adcenter.microsoft.com/api/customermanagement/Entities\">2013</Year>\n" +
                                                        "\t\t\t\t</EndDate>\n" +
                                                        "\t\t\t\t<GxAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">284894561564</GxAdGroupId>\n" +
                                                        "\t\t\t\t<BingAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">" + testUtil.adGroup11 + "</BingAdGroupId>\n" +
                                                        "\t\t\t\t<Name xmlns=\"https://adcenter.microsoft.com/v8\">AdGroup New Name 1</Name>\n" +
                                                        "\t\t\t\t<Network xmlns=\"https://adcenter.microsoft.com/v8\"/>\n" +
                                                        "\t\t\t\t<PhraseMatchBid xmlns=\"https://adcenter.microsoft.com/v8\">\n" +
                                                            "\t\t\t\t\t<Amount>38</Amount>\n" +
                                                        "\t\t\t\t</PhraseMatchBid>\n" +
                                                        "\t\t\t\t<PricingModel xmlns=\"https://adcenter.microsoft.com/v8\">Cpc</PricingModel>\n" +
                                                        "\t\t\t\t<StartDate xmlns=\"https://adcenter.microsoft.com/v8\">\n" +
                                                            "\t\t\t\t\t<Day xmlns=\"https://adcenter.microsoft.com/api/customermanagement/Entities\">13</Day>\n" +
                                                            "\t\t\t\t\t<Month xmlns=\"https://adcenter.microsoft.com/api/customermanagement/Entities\">3</Month>\n" +
                                                            "\t\t\t\t\t<Year xmlns=\"https://adcenter.microsoft.com/api/customermanagement/Entities\">2013</Year>\n" +
                                                        "\t\t\t\t</StartDate>\n" +
                                                        "\t\t\t\t<Status xmlns=\"https://adcenter.microsoft.com/v8\"/>\n" +
                                                    "\t\t\t</AdGroup>\n" +
                                                    "\t\t\t<AdGroup>\n" +
                                                        "\t\t\t\t<AdDistribution xmlns=\"https://adcenter.microsoft.com/v8\">Search</AdDistribution>\n" +
                                                        "\t\t\t\t<GxAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">284894561565</GxAdGroupId>\n" +
                                                        "\t\t\t\t<BingAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">" + testUtil.adGroup12 + "</BingAdGroupId>\n" +
                                                        "\t\t\t\t<Name xmlns=\"https://adcenter.microsoft.com/v8\">AdGroup Nuevo Name 2</Name>\n" +
                                                    "\t\t\t</AdGroup>\n" +
                                                "\t\t</AdGroupCollection>\n" +
                                            "\t</Bing_AdGroupsRequest>\n" +
                                            "\t<Bing_AdGroupsRequest xmlns=\"L2TMediaDev\">\n" +
                                                "\t\t<GxCampaignId>416149486</GxCampaignId>\n" +
                                                "\t\t<BingCampaignId>" + testUtil.campaignId2 + "</BingCampaignId>\n" +
                                                "\t\t<AdGroupCollection>\n" +
                                                    "\t\t\t<AdGroup>\n" +
                                                        "\t\t\t\t<AdDistribution xmlns=\"https://adcenter.microsoft.com/v8\">Content</AdDistribution>\n" +
                                                        "\t\t\t\t<BroadMatchBid xmlns=\"https://adcenter.microsoft.com/v8\">\n" +
                                                            "\t\t\t\t\t<Amount>220</Amount>\n" +
                                                        "\t\t\t\t</BroadMatchBid>\n" +
                                                        "\t\t\t\t<GxAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">284894561564</GxAdGroupId>\n" +
                                                        "\t\t\t\t<BingAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">" + testUtil.adGroup21 + "</BingAdGroupId>\n" +
                                                        "\t\t\t\t<Name xmlns=\"https://adcenter.microsoft.com/v8\">Nombre adGroup 21</Name>\n" +
                                                    "\t\t\t</AdGroup>\n" +
                                                    "\t\t\t<AdGroup>\n" +
                                                        "\t\t\t\t<GxAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">284894561565</GxAdGroupId>\n" +
                                                        "\t\t\t\t<BingAdGroupId xmlns=\"https://adcenter.microsoft.com/v8\">" + testUtil.adGroup22 + "</BingAdGroupId>\n" +
                                                        "\t\t\t\t<Name xmlns=\"https://adcenter.microsoft.com/v8\">Nombre segundo adGroup 22</Name>\n" +
                                                    "\t\t\t</AdGroup>\n" +
                                                "\t\t</AdGroupCollection>\n" +
                                            "\t</Bing_AdGroupsRequest>\n" +
                                        "</Bing_AdGroupsRequestCollection>\n";
        AdGroupManager resource = new AdGroupManager();
        System.out.println("Consuming UpdateAdGroups.....");
        String userName = testUtil.userName;
        String password = testUtil.password;
        String developerToken = testUtil.developerToken;
        long customerId = testUtil.customerId;
        long customerAccountId = testUtil.customerAccountId;
        String applicationId = testUtil.applicationId;
        String result = resource.updateAdGroups(customerAccountId, adGroupsRequestsXML);
        System.out.println("Result:\n" + result);
    }
}
